import pyautogui
import time

def Open_Wechat():
    # 模拟按下 Command 键
    pyautogui.keyDown('command')
    # 模拟按下 F 键
    pyautogui.press('space')
    # 释放 Command 和 F 键
    pyautogui.keyUp('command')
    pyautogui.write('weixin')
    pyautogui.press('Enter')
    pyautogui.press('Enter')
    time.sleep(1)

def Chat_Who(Who_Name):
    pyautogui.hotkey("command",'f')
    pyautogui.write(Who_Name)
    time.sleep(0.5)
    pyautogui.press('Enter')
    pyautogui.press('Enter')
    time.sleep(1)


def Sent_Msg(Msg):
    pyautogui.write(Msg)
    text = pyautogui.confirm(text='', title='', buttons=['OK', 'Cancel'])
    print(text)
    if(text == 'OK'):
         print("enter")
         pyautogui.press('Enter')

if __name__ == '__main__':
    Open_Wechat()
    Chat_Who('Mia')
    Sent_Msg('hello')
